/* Copyright 2013 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

/* Derived from /ui/webui/resources/css/menu.css. */

cr-menu {
  position: fixed;
  white-space: nowrap;
  z-index: 3;
}

cr-menu:not(.decorated) {
  display: none;
}

cr-menu > * {
  box-sizing: border-box;
  display: block;
  text-align: start;
  width: 100%;
}

cr-menu > hr {
  border: 0;
  height: 1px;
}

cr-menu > [hidden] {
  display: none;
}

cr-menu > [shortcutText]::after {
  color: var(--cros-menu-shortcut-color);
  content: attr(shortcutText);
  float: right;
  padding-inline-start: 30px;
}

cr-menu > [shortcutText][disabled]::after {
  color: var(--cros-text-color-disabled);
}

html[dir='rtl'] cr-menu > [shortcutText]::after {
  float: left;
}

cr-menu > [sub-menu]::after {
  -webkit-mask-image: url(../images/files/ui/arrow_right.svg);
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  background-color: var(--cros-icon-color-primary);
  content: '';
  float: right;
  height: 32px;
  width: 20px;
}

html[dir='rtl'] cr-menu > [sub-menu]::after {
  float: left;
  transform: scaleX(-1);
}

cr-menu > [sub-menu][disabled]::after {
  background-color: var(--cros-text-color-disabled);
}

/* Keeps menu visibile while animating. Fade out animation is performed by
   Javascript. */
cr-menu[hidden].files-menu.animating {
  opacity: 1;
  visibility: visible;
}

cr-menu.files-menu > cr-menu-item {
  align-items: center;
  display: flex;
  flex-direction: row;
  position: relative;
}

/* Icon on the left of the item label for cr.ui.FilesMenuItem.
   TODO(mtomasz): Upstream to cr.ui.MenuItem. */
cr-menu.files-menu cr-menu-item .icon {
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 16px 16px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  height: 32px;
  vertical-align: middle;
  width: 16px;
}

cr-menu.files-menu cr-menu-item .icon.start {
  align-self: flex-start;
  margin-inline-end: 8px;
}

cr-menu.files-menu:not(.has-icon-start) cr-menu-item .icon.start {
  display: none;
}

cr-menu.files-menu cr-menu-item .icon.managed {
  background-image: url(chrome://resources/images/business.svg);
  margin-inline-start: 8px;
}

cr-menu.files-menu cr-menu-item .icon.end {
  align-self: flex-end;
  margin-inline-start: 8px;
}

cr-menu.files-menu > cr-menu-item > .icon {
  z-index: 1;
}

cr-menu.files-menu > cr-menu-item > span,
cr-menu.files-menu > cr-menu-item > div:not(.icon) {
  flex-grow: 1;
  z-index: 1;
}

cr-menu.files-menu > cr-menu-item > paper-ripple {
  z-index: 0;
}

html.files-ng cr-menu.files-menu > cr-menu-item {
  padding: 0 16px;
}

html.files-ng.pointer-active cr-menu-item > paper-ripple {
  --paper-ripple-opacity: 100%;
  color: var(--cros-ripple-color);
}

html.files-ng cr-menu.files-menu > cr-menu-item:not([disabled])[selected],
html.files-ng cr-menu.files-menu > cr-menu-item:not([disabled]):active {
  background-color: var(--cros-menu-item-background-hover);
}

html.files-ng:not(.pointer-active) cr-menu.files-menu > cr-menu-item:not([disabled]):active[selected] {
  background-color: var(--cros-menu-item-background-hover);
}
